﻿
namespace DataAcquisition
{
    #region 设备
    public class DeviceItem : AntdUI.NotifyProperty
    {
        public DeviceItem(int number, string name, int slaveAddress, string portAddress, int baudRate)
        {
            _DeviceNumber = number;
            _DeviceName = name;
            _SlaveAddress = slaveAddress;
            _PortAddress = portAddress;
            _BaudRate = baudRate;
            _Operation = new AntdUI.CellLink[] {
                //new AntdUI.CellButton("edit") { BorderWidth=1, IconSvg="EditOutlined"},
                new AntdUI.CellButton("point") { BorderWidth=1, IconSvg="ApartmentOutlined"},
                new AntdUI.CellButton("delete") { BorderWidth=1, IconSvg="DeleteOutlined"},
            };
        }

        int _DeviceNumber;
        public int DeviceNumber
        {
            get => _DeviceNumber;
            set
            {
                if (_DeviceNumber == value) return;
                _DeviceNumber = value;
                OnPropertyChanged("DeviceNumber");
            }
        }

        string _DeviceName;
        public string DeviceName
        {
            get => _DeviceName;
            set
            {
                if (_DeviceName == value) return;
                _DeviceName = value;
                OnPropertyChanged("DeviceName");
            }
        }

        int _SlaveAddress;
        public int SlaveAddress
        {
            get => _SlaveAddress;
            set
            {
                if (_SlaveAddress == value) return;
                _SlaveAddress = value;
                OnPropertyChanged("SlaveAddress");
            }
        }

        string _PortAddress;
        public string PortAddress
        {
            get => _PortAddress;
            set
            {
                if (_PortAddress == value) return;
                _PortAddress = value;
                OnPropertyChanged("PortAddress");
            }
        }

        int _BaudRate;
        public int BaudRate
        {
            get => _BaudRate;
            set
            {
                if (_BaudRate == value) return;
                _BaudRate = value;
                OnPropertyChanged("baudRate");
            }
        }

        AntdUI.CellLink[] _Operation;
        public AntdUI.CellLink[] Operation
        {
            get => _Operation;
            set
            {
                _Operation = value;
                OnPropertyChanged("Operation");
            }
        }
    }
    #endregion

    #region 设备点位
    public class DevicePointItem : AntdUI.NotifyProperty
    {
        public DevicePointItem(
                       int deviceNumber, string deviceName,
                       int number, string name,
                       string address, string pointType, string range,
                       string outValue, string alarm, string errorRange,
                       string amend, string unit
                       )
        {
            _DeviceNumber = deviceNumber;
            _DeviceName = deviceName;
            _Number = number;
            _Name = name;
            _Address = address;
            _PointType = pointType;
            if (pointType == "Input" || pointType == "Holding")
            {
                _Range = range;
                _OutValue = outValue;
                _Alarm = alarm;
                _ErrorRange = errorRange;
                _Unit = unit;
                _Amend = amend;
            }
            else
            {
                _Range = "--";
                _OutValue = "--"; ;
                _Alarm = "--";
                _ErrorRange = "--";
                _Unit = "--";
                _Amend = "--";
            }
            _Operation = new AntdUI.CellLink[] {
                    //new AntdUI.CellButton("edit") { BorderWidth=1, IconSvg="EditOutlined"},
                    new AntdUI.CellButton("delete") { BorderWidth=1, IconSvg="DeleteOutlined"},
        };
        }

        int _DeviceNumber;
        public int DeviceNumber
        {
            get => _DeviceNumber;
            set
            {
                if (_DeviceNumber == value) return;
                _DeviceNumber = value;
                OnPropertyChanged("DeviceNumber");
            }
        }

        string _DeviceName = string.Empty;
        public string DeviceName
        {
            get => _DeviceName;
            set
            {
                if (_DeviceName == value) return;
                _DeviceName = value;
                OnPropertyChanged("DeviceName");
            }
        }

        int _DeviceAddress;
        public int DeviceAddress
        {
            get => _DeviceAddress;
            set
            {
                if (_DeviceAddress == value) return;
                _DeviceAddress = value;
                OnPropertyChanged("DeviceAddress");
            }
        }

        int _Number;
        public int Number
        {
            get => _Number;
            set
            {
                if (_Number == value) return;
                _Number = value;
                OnPropertyChanged("Number");
            }
        }

        string _Name = string.Empty;
        public string Name
        {
            get => _Name;
            set
            {
                if (_Name == value) return;
                _Name = value;
                OnPropertyChanged("Name");
            }
        }

        string _Address;
        public string Address
        {
            get => _Address;
            set
            {
                if (_Address == value) return;
                _Address = value;
                OnPropertyChanged("Address");
            }
        }

        string _PointType;
        public string PointType
        {
            get => _PointType;
            set
            {
                if (_PointType == value) return;
                _PointType = value;
                OnPropertyChanged("PointType");
            }
        }

        string _Range = string.Empty;
        public string Range
        {
            get => _Range;
            set
            {
                if (_Range == value) return;
                _Range = value;
                OnPropertyChanged("Range");
            }
        }

        string _OutValue = string.Empty;
        public string OutValue
        {
            get => _OutValue;
            set
            {
                if (_OutValue == value) return;
                _OutValue = value;
                OnPropertyChanged("OutValue");
            }
        }

        string _Alarm = string.Empty;
        public string Alarm
        {
            get => _Alarm;
            set
            {
                if (_Alarm == value) return;
                _Alarm = value;
                OnPropertyChanged("Alarm");
            }
        }

        string _ErrorRange = string.Empty;
        public string ErrorRange
        {
            get => _ErrorRange;
            set
            {
                if (_ErrorRange == value) return;
                _ErrorRange = value;
                OnPropertyChanged("ErrorRange");
            }
        }

        string _Amend;
        public string Amend
        {
            get => _Amend;
            set
            {
                if (_Amend == value) return;
                _Amend = value;
                OnPropertyChanged("Amend");
            }
        }

        string _Unit = string.Empty;
        public string Unit
        {
            get => _Unit;
            set
            {
                if (_Unit == value) return;
                _Unit = value;
                OnPropertyChanged("Unit");
            }
        }

        AntdUI.CellLink[] _Operation;
        public AntdUI.CellLink[] Operation
        {
            get => _Operation;
            set
            {
                _Operation = value;
                OnPropertyChanged("Operation");
            }
        }
    }
    #endregion

    #region 试压模板
    public class TemplateItem : AntdUI.NotifyProperty
    {
        public TemplateItem(string number, string pipePosition,
                       double designPressure,
                       int errorRange,
                       string firstStage,
                       string secondStage,
                       string thirdStage,
                       string intensityStage,
                       string rigorStage
                       )
        {
            _Number = number;
            _PipePosition = pipePosition;
            _DesignPressure = designPressure;
            _ErrorRange = errorRange;
            _FirstStage = firstStage.Length > 0 ? firstStage : "--";
            _SecondStage = secondStage.Length > 0 ? secondStage : "--";
            _ThirdStage = thirdStage.Length > 0 ? thirdStage : "--";
            _IntensityStage = intensityStage.Length > 0 ? intensityStage : "--";
            _RigorStage = rigorStage.Length > 0 ? rigorStage : "--";
            _Operation = new AntdUI.CellLink[] {
                       // new AntdUI.CellButton("edit") { BorderWidth=1, IconSvg="EditOutlined"},
                        new AntdUI.CellButton("delete") { BorderWidth=1, IconSvg="DeleteOutlined"},
            };
        }

        #region 属性
        string _Number;
        public string Number
        {
            get => _Number;
            set
            {
                if (_Number == value) return;
                _Number = value;
                OnPropertyChanged("Number");
            }
        }

        string _PipePosition = string.Empty;
        public string PipePosition
        {
            get => _PipePosition;
            set
            {
                if (_PipePosition == value) return;
                _PipePosition = value;
                OnPropertyChanged("PipePosition ");
            }
        }

        double _DesignPressure;
        public double DesignPressure
        {
            get => _DesignPressure;
            set
            {
                if (_DesignPressure == value) return;
                _DesignPressure = value;
                OnPropertyChanged("DesignPressure");
            }
        }

        string _FirstStage = string.Empty;
        public string FirstStage
        {
            get => _FirstStage;
            set
            {
                if (_FirstStage == value) return;
                _FirstStage = value;
                OnPropertyChanged("FirstStage ");
            }
        }

        string _SecondStage = string.Empty;
        public string SecondStage
        {
            get => _SecondStage;
            set
            {
                if (_SecondStage == value) return;
                _SecondStage = value;
                OnPropertyChanged("SecondStage ");
            }
        }

        string _ThirdStage = string.Empty;
        public string ThirdStage
        {
            get => _ThirdStage;
            set
            {
                if (_ThirdStage == value) return;
                _ThirdStage = value;
                OnPropertyChanged("ThirdStage ");
            }
        }

        string _IntensityStage = string.Empty;
        public string IntensityStage
        {
            get => _IntensityStage;
            set
            {
                if (_IntensityStage == value) return;
                _IntensityStage = value;
                OnPropertyChanged("IntensityStage ");
            }
        }

        string _RigorStage = string.Empty;
        public string RigorStage
        {
            get => _RigorStage;
            set
            {
                if (_RigorStage == value) return;
                _RigorStage = value;
                OnPropertyChanged("RigorStage");
            }
        }

        int _ErrorRange;
        public int ErrorRange
        {
            get => _ErrorRange;
            set
            {
                if (_ErrorRange == value) return;
                _ErrorRange = value;
                OnPropertyChanged("ErrorRange");
            }
        }

        AntdUI.CellLink[] _Operation = new AntdUI.CellLink[] { };
        public AntdUI.CellLink[] Operation
        {
            get => _Operation;
            set
            {
                _Operation = value;
                OnPropertyChanged("Operation");
            }
        }
        #endregion
    }
    #endregion

    #region 试压工程
    public class ProjectItem : AntdUI.NotifyProperty
    {

        public ProjectItem(
                           string number,
                           string name,
                           string stakeMark,
                           string pipeSpecification,
                           string pipeLength,
                           string medium,
                           double designPressure,
                           string pipeNature,
                           string testType,
                           string company,
                           string manometerPrecision,
                           string manometerRange,
                           string templateID
            )
        {
            _Number = number;
            _Name = name;
            _StakeMark = stakeMark;
            _PipeSpecification = pipeSpecification;
            _PipeLength = pipeLength;
            _Medium = medium;
            _DesignPressure = designPressure;
            _PipeNature = pipeNature;
            _Testtype = testType;
            _Company = company;
            _ManometerPrecision = manometerPrecision;
            _ManometerRange = manometerRange;
            _TemplateID = templateID;
            _Operation = new AntdUI.CellLink[] {
                        //new AntdUI.CellButton("edit") { BorderWidth=1, IconSvg="EditOutlined"},
                        new AntdUI.CellButton("delete") { BorderWidth=1, IconSvg="DeleteOutlined"} };
        }
        #region 属性
        string _Number = string.Empty;
        public string Number
        {
            get => _Number;
            set
            {
                if (_Number == value) return;
                _Number = value;
                OnPropertyChanged("Number");
            }
        }

        string _Name = string.Empty;
        public string Name
        {
            get => _Name;
            set
            {
                if (_Name == value) return;
                _Name = value;
                OnPropertyChanged("Name");
            }
        }

        string _StakeMark = string.Empty;
        public string StakeMark
        {
            get => _StakeMark;
            set
            {
                if (_StakeMark == value) return;
                _StakeMark = value;
                OnPropertyChanged("StakeMark");
            }
        }

        string _PipeSpecification = string.Empty;
        public string PipeSpecification
        {
            get => _PipeSpecification;
            set
            {
                if (_PipeSpecification == value) return;
                _PipeSpecification = value;
                OnPropertyChanged("PipeSpecification");
            }
        }

        string _PipeLength;
        public string PipeLength
        {
            get => _PipeLength;
            set
            {
                if (_PipeLength == value) return;
                _PipeLength = value;
                OnPropertyChanged("PipeLength");
            }
        }

        string _Medium = string.Empty;
        public string Medium
        {
            get => _Medium;
            set
            {
                if (_Medium == value) return;
                _Medium = value;
                OnPropertyChanged("Medium");
            }
        }

        double _DesignPressure;
        public double DesignPressure
        {
            get => _DesignPressure;
            set
            {
                if (_DesignPressure == value) return;
                _DesignPressure = value;
                OnPropertyChanged("DesignPressure");
            }
        }

        string _PipeNature = string.Empty;
        public string PipeNature
        {
            get => _PipeNature;
            set
            {
                if (_PipeNature == value) return;
                _PipeNature = value;
                OnPropertyChanged("PipeNature");
            }
        }

        string _Testtype = string.Empty;
        public string Testtype
        {
            get => _Testtype;
            set
            {
                if (_Testtype == value) return;
                _Testtype = value;
                OnPropertyChanged("Testtype");
            }
        }

        string _Company = string.Empty;
        public string Company
        {
            get => _Company;
            set
            {
                if (_Company == value) return;
                _Company = value;
                OnPropertyChanged("Company");
            }
        }

        string _ManometerPrecision = string.Empty;
        public string ManometerPrecision
        {
            get => _ManometerPrecision;
            set
            {
                if (_ManometerPrecision == value) return;
                _ManometerPrecision = value;
                OnPropertyChanged("ManometerPrecision");
            }
        }

        string _ManometerRange = string.Empty;
        public string ManometerRange
        {
            get => _ManometerRange;
            set
            {
                if (_ManometerRange == value) return;
                _ManometerRange = value;
                OnPropertyChanged("ManometerRange");
            }
        }

        string _TemplateID;
        public string TemplateID
        {
            get => _TemplateID;
            set
            {
                if (_TemplateID == value) return;
                _TemplateID = value;
                OnPropertyChanged("TemplateID");
            }
        }

        AntdUI.CellLink[] _Operation = new AntdUI.CellLink[] { };
        public AntdUI.CellLink[] Operation
        {
            get => _Operation;
            set
            {
                _Operation = value;
                OnPropertyChanged("Operation");
            }
        }

        #endregion
    }
    #endregion

    #region 界面点位
    public class FormPointItem : AntdUI.NotifyProperty
    {
        public FormPointItem(int number, string name, int devicePointNumber, string devicePointName, string pointType, int state)
        {
            _Number = number;
            _Name = name;
            if (state == 1) _State = new AntdUI.CellBadge(AntdUI.TState.Success, "启用");
            else _State = new AntdUI.CellBadge(AntdUI.TState.Error, "禁用");
            _DevicePointNumber = devicePointNumber;
            _DevicePointName = devicePointName;
            _PointType = pointType;
            _Operation = new AntdUI.CellLink[] {
                //new AntdUI.CellButton("edit") { BorderWidth=1, IconSvg="EditOutlined"},
                new AntdUI.CellButton("delete") { BorderWidth=1, IconSvg="DeleteOutlined"},
            };
        }

        int _Number;
        public int Number
        {
            get => _Number;
            set
            {
                if (_Number == value) return;
                _Number = value;
                OnPropertyChanged("Number");
            }
        }

        AntdUI.CellBadge _State;
        public AntdUI.CellBadge State
        {
            get => _State;
            set
            {
                _State = value;
                OnPropertyChanged("State");
            }
        }

        string _Name;
        public string Name
        {
            get => _Name;
            set
            {
                if (_Name == value) return;
                _Name = value;
                OnPropertyChanged("Name");
            }
        }

        int _DevicePointNumber;
        public int DevicePointNumber
        {
            get => _DevicePointNumber;
            set
            {
                if (_DevicePointNumber == value) return;
                _DevicePointNumber = value;
                OnPropertyChanged("DevicePointNumber");
            }
        }

        string _DevicePointName;
        public string DevicePointName
        {
            get => _DevicePointName;
            set
            {
                if (_DevicePointName == value) return;
                _DevicePointName = value;
                OnPropertyChanged("DevicePointName");
            }
        }

        string _PointType;
        public string PointType
        {
            get => _PointType;
            set
            {
                if (_PointType == value) return;
                _PointType = value;
                OnPropertyChanged("PointType");
            }
        }

        AntdUI.CellLink[] _Operation;
        public AntdUI.CellLink[] Operation
        {
            get => _Operation;
            set
            {
                _Operation = value;
                OnPropertyChanged("Operation");
            }
        }
    }
    #endregion

}
